# -*- coding: utf-8 -*-

import cv2 as cv

img = cv.imread("photos/dog.jpg")
cv.imshow("Dog", img)

# 调整图像大小
# # resize image
# resized = cv.resize(img, (500, 500))
# cv.imshow("Resized", resized)

# 裁剪图像
# cropping
# cropped = img[200:400, 200:400]
# cv.imshow("Cropped", cropped)

# 转成灰度图像 
# Converting to grayscale
# gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# cv.imshow("Gray", gray)

# 模糊 
# Blur
# blur = cv.GaussianBlur(img, (7,7), cv.BORDER_DEFAULT)
# cv.imshow("Blur", blur)

# 边缘检测
# Edge Cascade
canny = cv.Canny(img, 125, 175)
cv.imshow("Canny Edge", canny)

# 膨胀
# Dilating the image
dilated = cv.dilate(canny, (7,7), iterations=3)
cv.imshow("Dilated", dilated)

# 腐蚀
# Eroding
eroded = cv.erode(dilated, (7,7), iterations=3)
cv.imshow("Eroded", eroded)

cv.waitKey(0)